
const
  fs = require('fs')
  rollup = require('rollup')
  babel = require('rollup-plugin-babel')
  ujs = require('uglify-js')
  fcolor = {
    Green: "\x1b[32m",
    Yellow: "\x1b[33m",
    White: "\x1b[37m"
  }

rollup.rollup({

  entry: './src/pip.es6.js',

  plugins: [
    babel({
      exclude: 'node_modules/**'
    })
  ]

}).then(bundle => {

  let result = bundle.generate({
    format: 'umd',
    moduleName: 'pip'
  })

  fs.writeFile('dist/pip.js', result.code, err => {
    if(err) throw err
    console.log(fcolor.Green, 'pip.es6 🌈  pip.js ·········· 👌', fcolor.White)
  })

  result = ujs.minify(result.code, {
    fromString: true
  })

  fs.writeFile('dist/pip.min.js', result.code, err => {
    if(err) throw err
    console.log(fcolor.Green, 'pip.js 🌈  pip.min.js ······· 👌', fcolor.White)
  })

})

